<?php use_helper('Form'); ?>
<?php
$note_history = array_reverse($note_history);
?>


<?php slot('coursesNav', 'active') ?>
<div id="wrapper">
	<?php include_partial('global/systemMessages') ?>
	<div id="content">
	<!-- 
		<div id="location-bar">
			<form method="post" action="">
				<fieldset>
					<select>
						<option>Harvard</option>
					</select>
				</fieldset>
			</form>
			<ul class="breadcrumbs">
				<li class="first"><a href="#">Fall 2008</a> &#xBB;</li>
				<li><a href="#">Positive Psychology</a> &#xBB;</li>
				<li>Write Notes</li>
			</ul>
		</div>
	-->	
		<div id="main">
			<div class="main-heading">
				<p class="stars three">
					<span>3 stars</span>
					<a href="#">3<span> comments</span></a>
				</p>
				<h1>Lecture <?php echo $note->getNumber() ?>: <?php echo $note->getTopic()?></h1>
				<h2><?php echo $note->getCourse()->getSubject() ? $note->getCourse()->getSubject()->getName().":" : "" ?> <?php echo $note->getCourse()->getName() ?></h2>
			</div>
			<div class="notes">
				<?php if($sf_user->isAuthenticated() 
					&& ($note->getUserId() == $sf_user->getId() || $sf_user->isAdmin()
					|| $sf_user->isGroupAdmin($note->getGroupId())
					|| $sf_user->isGroupContributor($note->getGroupId()))): ?>
					<div style="text-align: right;">
						<?php echo link_to('Edit', 'notes/edit?id='.$note->getId())?> | 
						<?php echo link_to('View', 'notes/show?id='.$note->getId())?>
					</div>
				<?php endif ?>
			</div>


<?php echo form_tag('notes/compare?id=' . $note->getId()); ?>

<?php
foreach($note_history as $k=>$note) {
	if($k==0) {
		$note_title = 'Current Version';
	} elseif($k==(count($note_history)-1)) {
		$note_title = 'Original Version';
	} else {
		$note_title = sprintf("Revision #%d",$note->getVersion());
	}

	if($note->getDeleted()) {
		$note_desc = 'Deleted';
		$note_checkbox = '';
	} else {
		$note_desc = $note->getVersionComment();
		$note_checkbox = checkbox_tag('versions[]',$note->getVersion());
	}

	$note_date = date("F j, Y, g:i a",strtotime($note->getVersionCreatedAt()));
	$note_user_id = intval($note->getVersionCreatedBy()) ? intval($note->getVersionCreatedBy()) : $note->getUserId();
	$note_name = link_to($users[$note_user_id]['Username'],'profiles/show?id=' . $note_user_id);
	$note_viewlink = link_to('VIEW THIS VERSION &raquo;','notes/show?id=' . $note->getId() . '&version=' . $note->getVersion());


?>
	<div>
		<div><?php echo $note_checkbox; ?> <span style="font-size: 1.3em; color: #333;"><?php echo $note_title; ?></span>&nbsp;&nbsp;&nbsp;<span style="font-size: 0.8em; font-weight: bold;"><?php echo $note_viewlink; ?></span> <span style="float: right; color: #aaa;"><?php echo $note_date; ?></span></div>
		<div style="color: #aaa;"><?php echo $note_desc; ?></div>
		<div><?php echo $note_name; ?></div>
		<br />
	</div>

<?php } ?>

<?php echo submit_tag('Compare'); ?>
</form>

<br /><br />




			<?php include_component('comments','index', array('material' => $note)) ?>
		
		</div>
		
		<div id="sidebar">
			<?php include_component('courses', 'about', array('course_id' => $note->getCourseId()))?>		
		
			<?php include_component('notes', 'relatedGroups', array('course_id' => $note->getCourseId()))?>
			
			<?php include_component('notes', 'related', array('course_id' => $note->getCourseId()))?>

		</div>
	</div>
	
</div>
